<template>
  <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="图片地址" prop="url">
        <image-upload v-model="form.url"/>
      </el-form-item>
      <el-form-item label="监控地址id" prop="addressId">
        <el-input v-model="form.addressId" placeholder="请输入监控地址id"/>
      </el-form-item>
      <el-form-item label="差距范围" prop="rangeValue">
        <el-input v-model="form.rangeValue" placeholder="请输入差距范围"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </div>
</template>

<script>
import AddMixin from "@/minixs/basic/add"
import request from "@/utils/request";

export default {
  name: "add",
  mixins: [AddMixin],
  data() {
    return {
      // 表单数据
      form: {
        id: null,
        url: null,
        addressId: null,
        rangeValue: null,
        remark: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      },
      // 表单校验
      rules: {
        url: [
          {required: true, message: "图片地址不能为空", trigger: "blur"}
        ],
        addressId: [
          {required: true, message: "监控地址id不能为空", trigger: "blur"}
        ],
        rangeValue: [
          {required: true, message: "差距范围不能为空", trigger: "blur"}
        ],
      }
    }
  },
  methods: {
    // 保存数据
    save() {
      request({
        url: '/monitor/alarmimages',
        method: 'post',
        data: this.form
      }).then(response => {
        this.$modal.msgSuccess("新增成功");
        this.$emit("reload")
        this.cancel();
      });
    },
  }
};
</script>
